#include<bits/stdc++.h>

using namespace std;
using ll = long long;
ll a[3000], tot, n, from, to;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)cin >> a[i];
    sort(a, a + n);
    tot += a[n - 1] * a[n - 1];
    from = n - 1;
    to = 0;
    for (int i = 1; i < n; i++) {
        tot += (a[from] - a[to]) * (a[from] - a[to]);
        from = to;
        if (i % 2 == 1) {
            to = n - 2 - from;
        } else {
            to = n - 1 - from;
        }
    }
    cout << tot;

    return 0;
}